package com.pzhu.user.dao;

import com.mybatisflex.core.query.QueryCondition;
import com.pzhu.base.common.utils.mybatisflex.BaseService;
import com.pzhu.base.common.utils.mybatisflex.QueryUtils;
import com.pzhu.user.domain.entity.UserRole;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static com.pzhu.user.domain.entity.table.UserRoleTableDef.USER_ROLE;

/**
 * @author 75073
 * @description 针对表【user_role(用户角色关系表)】的数据库操作Mapper
 * @createDate 2024-02-19 00:37:22
 */
public interface UserRoleDAO extends BaseService<UserRole> {
     default  List<UserRole> listByUserId(Long userId) {
          if ( Objects.isNull(userId)){
               return Collections.emptyList();
          }
          QueryCondition condition = QueryUtils.and(
                  USER_ROLE.USER_ID.eq(userId)
          );
         return list(condition);
     }
}
